#ifndef WINSYSTEMTRAY_H
#define WINSYSTEMTRAY_H

#include "SystemTrayInterface.h"
#include <QWidget>
#include <QAbstractNativeEventFilter>
#include <QLabel>
#include "Windows.h"
#include "CMsgTrayPos.h"
#include <QSystemTrayIcon>

class WinSystemTray : public SystemTrayInterface,public QAbstractNativeEventFilter
{
    Q_OBJECT
private:
    NOTIFYICONDATA  m_nid;
    CMsgTrayPos     m_traypos;
    QLabel         *m_pSysIcon = nullptr;

    QMenu *m_menu = nullptr;
    QIcon m_icon;

    QTimer *m_blinkTimer = nullptr;
public:
    WinSystemTray(const QIcon &icon, QObject *parent);
    ~WinSystemTray();

    void setIcon(const QIcon &icon);
    void setContextMenu(QMenu *menu);
    void setVisible(bool visiable);

    void startBlink();
    void stopBink();

protected slots:
    void onBlinkTimeout();
protected:
    virtual bool nativeEventFilter(const QByteArray &eventType, void *message, long *result);
};
#endif // WINSYSTEMTRAY_H
